home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77663_nicdns_prop.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  21.4 KB  |  668 lines

  1. <% @Language=VbScript%>
  2. <% Option Explicit%>
  3. <%
  4.     '---------------------------------------------------------------------
  5.     ' nicdns_prop.asp: display and update the DNS properties of NIC.
  6.     '
  7.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  8.     '
  9.     ' Date            Description
  10.     ' 15-Jan-01        Creation Date.
  11.     ' 06-Mar-01        Modified Date    
  12.     '---------------------------------------------------------------------
  13. %>
  14.     <!-- #include virtual="/admin/inc_framework.asp"--->
  15.     <!-- #include file="loc_nicspecific.asp" -->
  16.     <!-- #include file="inc_network.asp" -->
  17. <% 
  18.     '---------------------------------------------------------------------
  19.     'Global Variables
  20.     '---------------------------------------------------------------------
  21.     Dim G_objService    'Instance of the WMI Connection
  22.     Dim page            'Variable that receives the output page object when 
  23.                         'creating a page 
  24.     Dim rc                'Return value for CreatePage
  25.     Dim SOURCE_FILE        'To get file name
  26.  
  27.     SOURCE_FILE = SA_GetScriptFileName()
  28.     
  29.     
  30.     '---------------------------------------------------------------------
  31.     'Form Variables
  32.     '---------------------------------------------------------------------
  33.     Dim F_ID            'ID of the Network Adapter
  34.     Dim F_radSelected    'Which option is selected
  35.                         ' "1" means DHCP enabled
  36.                         ' "2" means Manual Settings
  37.     Dim F_DNSserverList '"," seperated DNS Server list
  38.     
  39.     Dim F_strFlag        'To hold the Flag Value
  40.     
  41.     'to hold the registry path
  42.     Const G_CONST_REGISTRY_PATH ="SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
  43.     
  44.     'Create property page
  45.     rc=SA_CreatePage(L_DNSTASKTITLE_TEXT,"",PT_PROPERTY,page)
  46.     
  47.     'Serve the page
  48.     If(rc=0) then
  49.         SA_ShowPage(Page)
  50.     End if
  51.         
  52.     '-------------------------------------------------------------------------
  53.     'Function:                OnInitPage()
  54.     'Description:            Called to signal first time processing for this page.
  55.     '                        Use this method to do first time initialization tasks
  56.     'Input Variables:        PageIn,EventArg
  57.     'Output Variables:        PageIn,EventArg
  58.     'Returns:                True/False
  59.     'Global Variables:        None
  60.     '-------------------------------------------------------------------------
  61.     Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  62.         Call SA_TraceOut( SOURCE_FILE, "OnInitPage")
  63.         'getting default values of dns server settings
  64.         OnInitPage = SetDnsDefaultValues()
  65.     End Function
  66.     
  67.     '-------------------------------------------------------------------------
  68.     'Function:                OnServePropertyPage()
  69.     'Description:            Called when the page needs to be served.Use this 
  70.     '                        method to serve content
  71.     'Input Variables:        PageIn,EventArg
  72.     'Output Variables:        PageIn,EventArg
  73.     'Returns:                True/False
  74.     'Global Variables:        In:G_objService-Getting WMI connection Object
  75.     '                        In:F_iD-Getting NIC adapter Index
  76.     '                        In:F_radSelected-Getting radio button selection
  77.     '                        In:F_DNSserverList-Getting new list dns servers
  78.     '                        In:L_(*)-Localization content
  79.     '-------------------------------------------------------------------------
  80.     Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  81.         Dim objNetAdapter
  82.         Dim strDHCPEnabled
  83.         
  84.         Call SA_TraceOut( SOURCE_FILE, "OnServerPropertyPage")
  85.         
  86.         ' To get the Network Adapter object
  87.         set objNetAdapter =    getNetworkAdapterObject(G_objService,F_iD)
  88.         
  89.         'Get Whether the DHCP is enabled on the NIC.
  90.         strDHCPEnabled = isDHCPenabled(objNetAdapter)
  91.         
  92.         Call ServeCommonJavaScript()
  93.     %>    
  94.         <table width=518 valign=middle align=left border=0 cellspacing=0 cellpadding=2>
  95.             <tr>
  96.                 <td class='TasksBody' nowrap colspan=4><B><%=GetNicName(F_ID)%></B></td>
  97.             </tr>
  98.             
  99.             <tr>
  100.                 <td class='TasksBody' colspan=4> </td>
  101.             </tr>
  102.             
  103.             <tr>
  104.                 <td nowrap width=130px class='TasksBody'>
  105.                     <%=L_CONFIGURATION_TEXT%>
  106.                 </td>
  107.                 
  108.                 <td colspan="3" class='TasksBody'>
  109.                     <input type="RADIO" class="FormRadioButton" name="radIP" tabIndex=0 value="IPDEFAULT"
  110.                         <%     'if DHCP is disabled then disable
  111.                             'this radio button
  112.                             If Not strDHCPEnabled Then
  113.                                 response.write " Disabled "
  114.                             Else
  115.                                 response.write " Checked "
  116.                             End If
  117.                         %>
  118.                         onClick="EnableOK();disableDNSControls(true);" >
  119.                         <%= L_OBTAINIPFROMDHCP_TEXT%>
  120.                 </td>
  121.             </tr>
  122.             
  123.             <tr>
  124.                 <td class='TasksBody'>  </TD>
  125.                 <td nowrap colspan="3" class='TasksBody'>
  126.                     <input type="radio" class="FormRadioButton" NAME="radIP" tabIndex=1 value="IPMANUAL"
  127.                         <%
  128.                             'if DHCP is disabled then disable this radio button
  129.                             If  Ucase(F_strFlag)=Ucase("No") Then
  130.                                 Response.Write ""
  131.                             else
  132.                                 response.write " Checked "
  133.                             End If
  134.                         %>
  135.                          onClick="EnableOK(); enableDNSControls();" >
  136.                         <%=L_DNSCONFIGUREMANUALLY_TEXT%>
  137.                 </td>
  138.             </tr>
  139.             
  140.             <tr>
  141.                 <td align="RIGHT"  colspan=4 class='TasksBody'>
  142.                     <%=L_DNS_SERVER_ADDRESSES_TEXT%>
  143.                 </td>    
  144.             </tr>
  145.             
  146.             <tr height="22">
  147.                 <td nowrap valign="top" class='TasksBody'>
  148.                     <%=L_LIST_DNSSERVERS_TEXT%>
  149.                 </td>
  150.                 <td valign="top" class='TasksBody'>
  151.                     <select name="cboDNSServers" class="FormField" SIZE=6  tabIndex=2 STYLE="WIDTH: 225px" >
  152.                     <%OutputDNServersToListbox()%>
  153.                     </select>
  154.                 </td>
  155.             
  156.                 <td nowrap align=center valign="top" width="110" class='TasksBody'>
  157.                 <%
  158.                     Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT, "", "addDNSServerToListBox()", 60, 0, "DISABLED", "btnAddDNS")
  159.                 %>
  160.                     <br><br><br><br><br>
  161.                 <%
  162.                     Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT, "", "EnableOK();removeListBoxItems(document.frmTask.cboDNSServers,document.frmTask.btnRemoveDNS);EnableAddText()", 60, 0, "DISABLED", "btnRemoveDNS")
  163.                 %>
  164.                 </td>
  165.                 
  166.                 <td valign="top" class='TasksBody'>
  167.                     <input class='FormField' type="text" name="txtDNS" value="" size=20 maxlength=15  onKeyPress="checkKeyforIPAddress(txtDNS)" onkeyup="disableAddButton(this,document.frmTask.btnAddDNS)" tabIndex=3 onmouseup="disableAddButton(this,document.frmTask.btnAddDNS)">
  168.                 </td>
  169.                 
  170.             </tr>
  171.         
  172.         </table>
  173.  
  174.         <input type="hidden" name="hdnNicID" value="<%= F_ID %>">
  175.         <input type="HIDDEN" name="hdnDNSserverList" value="<%=F_DNSserverList%>">
  176.         <input type="HIDDEN" name="hdnRadioSelected" value="<%=F_radSelected%>">
  177. <%    
  178.         'destroying dynamically created objects
  179.         Set objNetAdapter=Nothing
  180.         OnServePropertyPage = True
  181.     End Function
  182.     
  183.     '-------------------------------------------------------------------------
  184.     'Function:                OnPostBackPage()
  185.     'Description:            Called to signal that the page has been posted-back.
  186.     'Input Variables:        PageIn,EventArg
  187.     'Output Variables:        PageIn,EventArg
  188.     'Returns:                True/False
  189.     'Global Variables:        None
  190.     '-------------------------------------------------------------------------
  191.     Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  192.         
  193.         Call SA_TraceOut( SOURCE_FILE, "OnPostBackPage")
  194.         OnPostBackPage = True
  195.     End Function
  196.         
  197.     '-------------------------------------------------------------------------
  198.     'Function:                OnSubmitPage()
  199.     'Description:            Called when the page has been submitted for processing.
  200.     '                        Use this method to process the submit request.
  201.     'Input Variables:        PageIn,EventArg
  202.     'Output Variables:        PageIn,EventArg
  203.     'Returns:                True/False
  204.     'Global Variables:        In: G_objService-Getting WMI connection Object
  205.     '                        Out:F_iD-Getting NIC adapter Index
  206.     '                        Out:F_radSelected-Getting radio button selection
  207.     '                        Out:F_DNSserverList-Getting new list dns servers
  208.     '                        In: L_(*)-Localization content
  209.     '-------------------------------------------------------------------------
  210.     Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  211.         Call SA_TraceOut( SOURCE_FILE, "OnSubmitPage")
  212.         
  213.         'Nic adapter index no
  214.         F_ID = Request.Form("hdnNicID")
  215.         
  216.         'Dns servers list after form has been submiited
  217.         F_DNSserverList = Request.Form("hdnDNSserverList")
  218.  
  219.         ' The radio button to be selected - contains 1 or 2 only
  220.         F_radSelected = Request.Form("hdnRadioSelected")
  221.         
  222.         'Getting WMI connection Object on error displays failure page
  223.         Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  224.         
  225.         'Updating the dsn server settings
  226.         If UpdateDNSSettingsForNIC() Then
  227.             OnSubmitPage = true
  228.         Else
  229.             OnSubmitPage = false
  230.         End If    
  231.     
  232.     End Function
  233.            
  234.     '-------------------------------------------------------------------------
  235.     'Function:                OnClosePage()
  236.     'Description:            Called when the page is about closed.Use this method
  237.     '                        to perform clean-up processing
  238.     'Input Variables:        PageIn,EventArg
  239.     'Output Variables:        PageIn,EventArg
  240.     'Returns:                True/False
  241.     'Global Variables:        None
  242.     '-------------------------------------------------------------------------
  243.     Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  244.         Call SA_TraceOut( SOURCE_FILE, "OnClosePage")
  245.         Set G_objService = nothing
  246.         OnClosePage = TRUE
  247.     End Function     
  248.     
  249.     '-------------------------------------------------------------------------
  250.     'Function:                ServeCommonJavaScript
  251.     'Description:            Serves in initializing the values,setting the form
  252.     '                        data and validating the form values
  253.     'Input Variables:        None
  254.     'Output Variables:        None
  255.     'Returns:                True/False
  256.     'Global Variables:        None
  257.     '-------------------------------------------------------------------------
  258.     Function ServeCommonJavaScript()
  259.         Err.Clear
  260.         On Error Resume Next
  261.         
  262.         Call SA_TraceOut( SOURCE_FILE, "ServeCommonJavaScript")
  263. %>        
  264.         <script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  265.         </script>
  266.         <script language="JavaScript">
  267.             //global value to hold the frmTask Object
  268.             var FrmObj
  269.             
  270.             //
  271.             // Microsoft Server Appliance Web Framework Support Functions
  272.             // Copyright (c) Microsoft Corporation.  All rights reserved. 
  273.             //
  274.             // Init Function
  275.             // -----------
  276.             // This function is called by the Web Framework to allow the page
  277.             // to perform first time initialization. 
  278.             //
  279.             // This function must be included or a javascript runtime error will occur.
  280.             //
  281.             
  282.             function Init()
  283.             {
  284.                 FrmObj = eval(document.frmTask)
  285.                 //Disable the DNS server address text box if dns server listbox already  contains 20 items
  286.                 if(FrmObj.cboDNSServers.length>=20)
  287.                     {document.frmTask.txtDNS.disabled = true}
  288.                 else                                    
  289.                     {document.frmTask.txtDNS.disabled = false}
  290.                     
  291.                 if(FrmObj.radIP[1].checked && FrmObj.cboDNSServers.length >0 )
  292.                     FrmObj.cboDNSServers.options[0].selected = true;
  293.  
  294.                 if(FrmObj.radIP[0].checked)
  295.                     disableDNSControls(true);
  296.                 else if(FrmObj.cboDNSServers.length< 20) 
  297.                 {                    
  298.                     enableDNSControls();
  299.                     
  300.                 }
  301.                 
  302.                 //Checking for 0 length list if so make
  303.                 if (FrmObj.cboDNSServers.length==0)
  304.                 {
  305.                     FrmObj.btnRemoveDNS.disabled=true;
  306.                 }
  307.                 //function call to disable add button of DNS
  308.                 disableAddButton(FrmObj.txtDNS,FrmObj.btnAddDNS)
  309.             }
  310.             // end of function Init()
  311.  
  312.             // ValidatePage Function
  313.             // ------------------
  314.             // This function is called by the Web Framework as part of the
  315.             // submit processing. Use this function to validate user input. Returning
  316.             // false will cause the submit to abort. 
  317.             //
  318.             // This function must be included or a javascript runtime error will occur.
  319.             //
  320.             // Returns: True if the page is OK, false if error(s) exist. 
  321.             
  322.             function ValidatePage()
  323.             {
  324.                 return true;
  325.             }
  326.  
  327.             // SetData Function
  328.             // --------------
  329.             // This function is called by the Web Framework and is called
  330.             // only if ValidatePage returned a success (true) code. Typically you would
  331.             // modify hidden form fields at this point. 
  332.             //
  333.             // This function must be included or a javascript runtime error will occur.
  334.             //
  335.             // function to set the hidden field with the selected DNS server
  336.             // list values
  337.             function SetData()
  338.             {
  339.                 var nIndex
  340.                 var strDNSServer
  341.                 strDNSServer =""
  342.                 
  343.                 
  344.                 for(nIndex= 0; nIndex < FrmObj.cboDNSServers.length; nIndex++)
  345.                 {
  346.                     if(nIndex==20)
  347.                         {
  348.                         break;
  349.                         }
  350.                     strDNSServer = strDNSServer +
  351.                              FrmObj.cboDNSServers.options[nIndex].value + ",";
  352.                 }
  353.                     
  354.                 FrmObj.hdnDNSserverList.value = strDNSServer
  355.                 if(FrmObj.radIP[0].checked)
  356.                     FrmObj.hdnRadioSelected.value = "1"
  357.                 else
  358.                     FrmObj.hdnRadioSelected.value = "2"
  359.  
  360.             }
  361.             
  362.             // Depending on the flag the controls lisbox, textbox, Add &
  363.             // remove buttons are disabled or enabled
  364.             function disableDNSControls(strFlag)
  365.             {
  366.                 if ( strFlag ) 
  367.                 {
  368.  
  369.                     FrmObj.btnRemoveDNS.disabled = true;
  370.                     FrmObj.btnAddDNS.disabled = true;
  371.                     FrmObj.txtDNS.disabled = true;
  372.                     if(FrmObj.cboDNSServers.length > 0)
  373.                     {
  374.                         FrmObj.cboDNSServers.selectedIndex = -1;
  375.                     }
  376.                     FrmObj.cboDNSServers.disabled = true;
  377.                 }
  378.                 else
  379.                 {
  380.                     FrmObj.btnRemoveDNS.disabled = false;
  381.                     FrmObj.btnAddDNS.disabled = false;
  382.                 }
  383.             }
  384.             
  385.  
  386.             function enableDNSControls()
  387.             {
  388.                 FrmObj.txtDNS.disabled = false;
  389.                 FrmObj.txtDNS.value=""
  390.                 FrmObj.txtDNS.focus()
  391.                 FrmObj.cboDNSServers.disabled = false;
  392.                 
  393.                 // if any dns entries present, select the first
  394.                 // and enable the Remove button
  395.                 if(FrmObj.cboDNSServers.length > 0)
  396.                 {
  397.                     FrmObj.cboDNSServers.selectedIndex = 0;
  398.                     FrmObj.btnRemoveDNS.disabled = false;                    
  399.                 }
  400.             }
  401.                 
  402.  
  403.             // Adds the value in the text box in to the listbox
  404.             function addDNSServerToListBox()
  405.             {
  406.                 var intErrorNumber                
  407.                 intErrorNumber = isValidIP(FrmObj.txtDNS)
  408.                 if( intErrorNumber != 0)
  409.                 {
  410.                     assignErrorString(intErrorNumber)
  411.                     document.onkeypress=ClearErr;
  412.                     FrmObj.btnAddDNS.disabled = true;
  413.                     FrmObj.txtDNS.focus()
  414.                     return false;
  415.                 }
  416.                 else
  417.                 {
  418.                     if(!addToListBox(FrmObj.cboDNSServers,FrmObj.btnRemoveDNS,FrmObj.txtDNS.value,FrmObj.txtDNS.value))
  419.                     {
  420.                         SA_DisplayErr('<%=SA_EscapeQuotes(L_DUPLICATEDNS_ERRORMESSAGE)%>');
  421.                         document.onkeypress=ClearErr;
  422.                         return false;
  423.                     }
  424.                     else
  425.                     {
  426.                         FrmObj.txtDNS.value="";
  427.                         FrmObj.txtDNS.focus();
  428.                     }
  429.                 }
  430.                 EnableOK()
  431.                 
  432.                 //Enable the DNS server address text box if dns server listbox contains less than 20 items
  433.                 EnableAddText()            
  434.                     
  435.             }
  436.  
  437.             // Function to make the add button disable
  438.             function disableAddButton(objText,objButton)
  439.             {
  440.                 
  441.                 if(Trim(objText.value)=="")
  442.                     objButton.disabled=true;
  443.                 else
  444.                     objButton.disabled=false;
  445.             }
  446.  
  447.             //Function to assign Error strings based on the Input number
  448.             function assignErrorString(intErrorNumber)
  449.             {
  450.                 switch( intErrorNumber)
  451.                 {
  452.                     case 1:
  453.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_ENTERVALIDIP_ERRORMESSAGE)%>');
  454.                             break;
  455.                     case 2:
  456.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_INVALIDIPFORMAT_ERRORMESSAGE)%>');
  457.                             break;
  458.                     case 4:
  459.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_IPSTART_ERRORMESSAGE)%>');
  460.                             break;
  461.                     case 5:
  462.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_IPLOOPBACK_ERRORMESSAGE)%>');
  463.                             break;
  464.                     case 6:
  465.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_IPBOUNDSEXCEEDED_ERRORMESSAGE)%>');
  466.                             break;
  467.                     case 8:
  468.                             SA_DisplayErr ( '<%=SA_EscapeQuotes(L_ZEROSTARTIP_ERRORMESSAGE)%>');
  469.                             break;        
  470.                 }
  471.                 
  472.             }
  473.             
  474.             //Enable the DNS server address text box if dns server listbox contains less than 20 items
  475.             function EnableAddText()
  476.             
  477.             {
  478.                 FrmObj = eval(document.frmTask)
  479.                 
  480.                 if(FrmObj.cboDNSServers.length>=20)
  481.                     FrmObj.txtDNS.disabled = true;
  482.                 else    
  483.                     FrmObj.txtDNS.disabled = false;    
  484.             }
  485.             
  486.             
  487.         </script>
  488. <%    
  489.     End Function
  490.  
  491.     '---------------------------------------------------------------------
  492.     ' Function name:        UpdateDNSSettingsForNIC
  493.     ' Description:            To update the DNS Settings for the Network Card.
  494.     ' Input Variables:        None
  495.     ' Output Variables:        None
  496.     ' Returns:                true on success; otherwise false
  497.     'Global Variables:        In:G_objService-Getting WMI connection Object
  498.     '                        In:F_ID-Getting NIC adapter Index
  499.     '                        In:F_radSelected-Getting radio button selection
  500.     '                        In:L_(*)-Localization content    
  501.     '---------------------------------------------------------------------
  502.     Function UpdateDNSSettingsForNIC()
  503.         Err.Clear
  504.         On Error Resume Next
  505.         
  506.         Dim objNetAdapter    'To hold Network adapter object
  507.         Dim intReturnValue    'To hold the return value
  508.         Dim strSettingId    'To hold the registry setting value
  509.         Dim objRegistry        'To hold the registry object
  510.         
  511.         Call SA_TraceOut( SOURCE_FILE, "UpdateDNSSettingsForNIC")
  512.             
  513.         UpdateDNSSettingsForNIC = false
  514.  
  515.         ' Getting the Network adapter objects & DNS servers list
  516.         set objNetAdapter =    getNetworkAdapterObject(G_objService,F_ID)
  517.         
  518.         strSettingId=objNetAdapter.SettingID
  519.         
  520.         'Connecting to default namespace to carry registry operations
  521.         Set objRegistry=regConnection()
  522.             
  523.         If (objRegistry is Nothing) Then
  524.             Call SA_TraceOut( SOURCE_FILE, "Error in getting registry object-UpdateDNSSettingsForNIC()")
  525.             SA_ServeFailurePage(L_SERVERCONNECTIONFAIL_ERRORMESSAGE)
  526.             UpdateDNSSettingsForNIC = False
  527.             Exit Function
  528.         End If
  529.         
  530.         
  531.         'If the DNS server is to be obtained dynamically
  532.         If F_radSelected = "1" Then
  533.  
  534.             'Check whether DHCP is enabled
  535.             If isDHCPEnabled(objNetAdapter) Then
  536.                 intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID,"NameServer","",CONST_STRING)
  537.             Else
  538.                 SA_SetErrMsg L_DHCPDISABLED_ERRORMESSAGE & "(" & Hex(Err.number) & ")"
  539.                 Exit Function
  540.             End If
  541.         Else
  542.             'removing the last comma from dns server list
  543.             F_DNSserverList=Mid(F_DNSserverList,1, len(F_DNSserverList)-1)
  544.             'Set the DNS server list in the WMI
  545.             intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID,"NameServer",F_DNSserverList,CONST_STRING)
  546.         End If
  547.     
  548.         If Err.number  <> 0 Then
  549.             Call SA_TraceOut( SOURCE_FILE, "DNS settings Not set-UpdateDNSSettingsForNIC()")
  550.             Call SA_ServeFailurePage( L_DNSSETTINGSNOTSET_ERRORMESSAGE)
  551.             UpdateDNSSettingsForNIC=False
  552.             Exit Function                
  553.         End If
  554.  
  555.         set objNetAdapter = Nothing
  556.         UpdateDNSSettingsForNIC = intReturnValue
  557.  
  558.     End Function
  559.     
  560.     '---------------------------------------------------------------------
  561.     ' Function name:        SetDnsDefaultValues()
  562.     ' Description:            Setting the dns server default values
  563.     ' Input Variables:        None
  564.     ' Output Variables:        None
  565.     ' Returns:                True if its a success; False otherwise
  566.     'Global Variables:        In:G_objService-Getting WMI connection Object
  567.     '                        Out:F_ID-Getting NIC adapter Index
  568.     '                        Out:F_radSelected-Getting radio button selection
  569.     '                        In:L_(*)-Localization content    
  570.     '---------------------------------------------------------------------    
  571.     Function SetDnsDefaultValues()
  572.         Err.Clear
  573.         On Error Resume Next
  574.         
  575.         Dim objNetAdapter        'To hold nic adapter object
  576.         Dim objRegistry            'To hold registry object
  577.         Dim strNameServer        'To hold the dns servers list
  578.         Dim strSettingId        'To hold registry setting id
  579.             
  580.         Const DHCPON="ON"        'Constant for DHCP On
  581.         COnst DHCPOFF="OFF"        'Constant for DHCP Off
  582.         Const CONSTFLAGNO="No"    'Constant for for flag value
  583.         
  584.         Call SA_TraceOut( SOURCE_FILE, "SetDnsDefaultValues()")
  585.         
  586.         'Connecting to default namespace to carry registry operations
  587.         Set objRegistry=regConnection()
  588.             
  589.         If (objRegistry is Nothing) Then
  590.             Call SA_TraceOut( SOURCE_FILE, "Error in getting registry object-SetDnsDefaultValues()")
  591.             SA_ServeFailurePage(L_SERVERCONNECTIONFAIL_ERRORMESSAGE) 
  592.             UpdateDNSSettingsForNIC = False
  593.             Exit Function
  594.         End If
  595.         
  596.         'getting dns setting from area page
  597.         F_ID = Request.QueryString("PKey")
  598.         
  599.         If F_ID = "" Then
  600.             Call SA_TraceOut( SOURCE_FILE, "Dns settings not retrieved-SetDnsDefaultValues()")
  601.             Call SA_ServeFailurePage(L_DNSSETTINGSNOTRETRIEVED_ERRORMESSAGE)
  602.             SetDnsDefaultValues=False
  603.             Exit Function
  604.         End If
  605.                 
  606.         'Getting WMI connection Object on error displays failure page
  607.         Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  608.         
  609.         'To get the Network Adapter object
  610.         set objNetAdapter =    getNetworkAdapterObject(G_objService,F_ID)
  611.         
  612.         strSettingId=objNetAdapter.SettingID
  613.         
  614.         strNameServer=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _
  615.         & strSettingId,"NameServer",CONST_STRING)
  616.             
  617.         If strNameServer="" and isDHCPenabled(objNetAdapter) then
  618.             F_strFlag=CONSTFLAGNO
  619.         Else
  620.             ''getting the dns server list
  621.             F_DNSserverList=strNameServer
  622.         End If         
  623.  
  624.         'checking for the DHCP is enabled or not
  625.         If isDHCPenabled(objNetAdapter) Then
  626.             F_radSelected = DHCPON
  627.         Else
  628.             F_radSelected = DHCPOFF
  629.         End If
  630.         
  631.         SetDnsDefaultValues=True
  632.     End Function        
  633.     
  634.     '-------------------------------------------------------------------------
  635.     ' Function Name:        OutputDNSServersToListbox
  636.     ' Description:            To display the DNS Servers in the LISTBOX.
  637.     ' Input Variables:        None.
  638.     ' Output Variables:        None.
  639.     ' Returns:                None.
  640.     ' Global Variables:     In:  F_DNSserverList - *-separated list of DNS servers IPs
  641.     ' This function Outputs DNS servers to the listbox control in the Form.
  642.     '-------------------------------------------------------------------------
  643.     Function OutputDNServersToListbox()
  644.         Err.Clear    
  645.         On Error Resume Next
  646.                 
  647.         Dim arrDnsSrv    'To hold the dns servers list
  648.         Dim nIndex        'To hold the array index
  649.         
  650.         arrDnsSrv = split(F_DNSserverList,",")
  651.         
  652.         nIndex = 0
  653.         If (NOT IsNull(arrDnsSrv)) Then
  654.             If IsArray(arrDnsSrv) Then
  655.                 For nIndex = LBound(arrDnsSrv) to UBound(arrDnsSrv)
  656.                     If arrDnsSrv(nIndex) <> "" Then
  657.                         Response.Write "<OPTION VALUE=""" & arrDnsSrv(nIndex) & _
  658.                                 """ >" & arrDnsSrv(nIndex) & " </OPTION>"
  659.                     End If
  660.                 Next
  661.             End If
  662.         End If
  663.  
  664.     End Function
  665. %>    
  666.  
  667.  
  668.